﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Common;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace MapComponentSprite
{
    public class MapUnitSprite : AutomatedSprite
    {
        /// <summary>
        /// 位图单元编号
        /// </summary>
        public string NumberName { get; set; }
        public Rectangle Destination = new Rectangle();

        /// <summary>
        /// 地图单元所在窗口中的【列,行】
        /// </summary>
        public Point Position { get; set; }
        public override void Draw(GameTime gameTime)
        {
            LoadPic();
            SpriteBatch.Draw(this.Image, this.Destination, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.9f);
        }

        public override void Update(GameTime gameTime)
        {

        }

        private void LoadPic()
        {
            if (this.Image == null)
                this.Image = Game.Content.Load<Texture2D>(@"Images\maps\" + NumberName);
        }
    }
}
